package com.javaee.service.doctor.impl;

import com.javaee.entity.Mzgh;
import com.javaee.entity.Record;
import com.javaee.mapper.doctor.DRecordMapper;
import com.javaee.service.doctor.DRecordService;
import org.commonmark.node.Node;
import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DRecordServiceImpl implements DRecordService {
    @Autowired
    private DRecordMapper dRecordMapper;

    @Override
    public List<Record> findByDoctorId(int pageNum, int pageSize, int dId) {
        return dRecordMapper.findByDoctorId(pageNum,pageSize,dId);
    }

    @Override
    public int selectCount(int dId) {
        return dRecordMapper.selectCount(dId);
    }

    @Override
    public Record findARecordById(int id) {
        return dRecordMapper.findARecordById(id);
    }

    @Override
    public void addRecord(Record record) {
        dRecordMapper.addRecord(record);
    }

    @Override
    public String selectCnoByUId(int uId) {
        return dRecordMapper.selectCnoByUId(uId);
    }

    @Override
    public Mzgh selectByMId(int mId) {
        return dRecordMapper.selectByMId(mId);
    }

    @Override
    public List<Integer> findAllMIds() {
        return dRecordMapper.findAllMIds();
    }

    @Override
    public String convertMarkdownToHtml(String markdownContent) {
        Parser parser = Parser.builder().build();
        Node document = parser.parse(markdownContent);
        HtmlRenderer renderer = HtmlRenderer.builder().build();
        return renderer.render(document);
    }
}
